package com.central.test

import com.central.service.{GangFindCondition, GangFindService}
import com.central.utils.ConfigUtil
import org.apache.spark.sql.SparkSession

object TestGang {
  def main(args: Array[String]): Unit = {

    try {
      if (args.length == 0) {
        //        val jsb: JSONObject = JSON.parseObject(args.apply(0))
        val jobId = "1" //jsb.get("jobId") + ""
        val code_type = "imsi"
        val code = "460048832321410"
        val endtime = "2020-02-27 00:00:00"
        val starttime = "2020-01-10 00:00:00"
        val activitytime = "09:00:00,18:00:00"
        val device_codes = "2,3,4,5,6,7,26,1"
        val hashisrelation=1
        val hascriminalrecord=0
        val hasliferow=0
        val accumulatedays=10
        val condition = GangFindCondition(code, code_type, jobId, device_codes, activitytime,starttime,endtime,hashisrelation,hascriminalrecord,hasliferow,accumulatedays) //如果结束时间和开始时间相等,则取最大Long值

        val para1 = SparkSession
          .builder()
          .appName(jobId)
          .master("local")
          .config("es.nodes", ConfigUtil.properties.getProperty("elasticsearch.host", "192.168.5.180"))
          .config("es.port", ConfigUtil.properties.getProperty("elasticsearch.port", "9200"))
          .config("es.mapping.date.rich", "false")

          .getOrCreate()
        para1.sparkContext.setLogLevel("ERROR")
        //        new ClueService().following(para1, jobId, condition, threshold)
        new GangFindService().findCrime(para1, condition)
      } else {
      }
    }
    catch {
      case e: Exception => {
        println(e.getMessage)
      }
    }
  }
}
